﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CountSystem : IGameSystem {
	private Text scoreText;

	private int currentCount = 0;
	private Mediator m_mediator;

	public CountSystem (Mediator mediator) {
		this.m_mediator = mediator;
		scoreText = GameObject.Find ("CountText").GetComponent<Text> ();
	}
	public int CurrentCount {
		get { return currentCount; }
	}
	public void OnUpdate () {
		
	}
	public void OnEnd () {
		for (int i = 0; i < m_mediator.constructionSystem.gameobjectList.Count; i++)
		{
			if (m_mediator.constructionSystem.gameobjectList[i].transform.position.y>-3){
				currentCount++;
			}
		}
		scoreText.text = "当前总数：" + currentCount.ToString () + "\n"+"按空格重新开始";
	}
	public void OnStart () {
		currentCount = 0;
		scoreText.text = currentCount.ToString ();
	}
}